//
//  ScheduleCell.m
//  FDCalendarDemo
//
//  Created by 孙添凤 on 17/1/20.
//  Copyright © 2017年 fergusding. All rights reserved.
//

#import "ScheduleCell.h"
#import "Masonry.h"
#import "UIColor+CL.h"
@implementation ScheduleCell

-(instancetype)initWithidentirier:(NSString *)identifier{
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    if(self){
        UIView *v = [self createUI];
        // UIView要加入到self.contentView上 不要加入到self
        [self.contentView addSubview:v];
        UIView *superview = self.contentView;
        UIEdgeInsets edge = UIEdgeInsetsMake(0, 0, 0, 0);
        [v mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(superview).insets(edge);
        }];

    }
    return self;
}

-(UIView *)createUI{
    UIView *baseView = [[UIView alloc]init];
    baseView.backgroundColor =[UIColor whiteColor];
    
    UIImageView *backView =[[UIImageView alloc]init];
    backView.image =[UIImage imageNamed:@"ffac56_bg"];
    [baseView addSubview:backView];
    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseView.mas_left).offset(7);
        make.right.equalTo(baseView.mas_right).offset(-7);
        make.top.equalTo(baseView.mas_top).offset(10);
        make.bottom.equalTo(baseView.mas_bottom);
    }];
    
    _startTime =[[UILabel alloc]init];
    [backView addSubview:_startTime];
    [_startTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(backView.mas_left).offset(10);
        make.top.equalTo(backView.mas_top).offset(15);
        make.height.equalTo(@(15));
    }];
    _startTime.font =[UIFont systemFontOfSize:15];
    _startTime.text = @"12:00";
    _startTime.textColor =[UIColor whiteColor];
    
    UILabel *la =[[UILabel alloc]init];
    [backView addSubview:la];
    [la mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_startTime.mas_centerX);
        make.centerY.equalTo(backView.mas_centerY);
    }];
    la.font =[UIFont systemFontOfSize:15];
    la.textColor =[UIColor whiteColor];
    la.text = @"~";
    
    
    _endTime =[[UILabel alloc]init];
    [backView addSubview:_endTime];
    [_endTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(backView.mas_left).offset(10);
        make.bottom.equalTo(backView.mas_bottom).offset(-15);
        make.height.equalTo(@(15));
    }];
    _endTime.font =[UIFont systemFontOfSize:15];
    _endTime.text = @"13:00";
    _endTime.textColor =[UIColor whiteColor];
    
    
    _classNum =[[UILabel alloc]init];
    [backView addSubview:_classNum];
    [_classNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(backView.mas_top).offset(10);
        make.left.equalTo(_endTime.mas_right).offset(25+5);
        make.width.equalTo(@(250));
    }];
    _classNum.font =[UIFont systemFontOfSize:15];
    _classNum.textColor =[UIColor whiteColor];
    _classNum.text = @"班号：20160912";

    
//    _courseName =[[UILabel alloc]init];
//    [backView addSubview:_courseName];
//    [_courseName mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(_classNum.mas_bottom).offset(11);
//        make.left.equalTo(_startTime.mas_right).offset(22);
//    }];
//    _courseName.font =[UIFont systemFontOfSize:16];
//    _courseName.text = @"中文版ps-ps4实例与操作";
//    _courseName.textColor =[UIColor whiteColor];
//
    _couresType =[[UILabel alloc]init];
    [backView addSubview:_couresType];
    [_couresType mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(backView.mas_top).offset(5);
        make.right.equalTo(backView.mas_right).offset(-6);
        make.height.equalTo(@(19));
        make.width.equalTo(@(43));
    }];
    _couresType.font =[UIFont systemFontOfSize:12];
    _couresType.textColor =[UIColor colorWithHex:0xff8200];
    _couresType.text = @"周末班";
    _couresType.backgroundColor =[UIColor whiteColor];
    _couresType.layer.cornerRadius = 10;
    _couresType.layer.masksToBounds= YES;
    _couresType.textAlignment = NSTextAlignmentCenter;
    
//    _keci =[[UILabel alloc]init];
//    [backView addSubview:_keci];
//    [_keci mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(backView.mas_top).offset(35);
//        make.right.equalTo(backView.mas_right).offset(-9);
//    }];
//    _keci.font =[UIFont systemFontOfSize:14];
//    _keci.text = @"第2次课";
//    _keci.textColor =[UIColor colorWithHex:0x9c5000];
    
    
    UIImageView *teacherImg =[[UIImageView alloc]init];
    [backView addSubview:teacherImg];
    [teacherImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_classNum.mas_bottom).offset(11);
        make.left.equalTo(_startTime.mas_right).offset(25+3);
        make.width.equalTo(@(13));
        make.height.equalTo(@(13));
    }];
    teacherImg.image =[UIImage imageNamed:@"campus"];
    
    _teacherName =[[UILabel alloc]init];
    [backView addSubview:_teacherName];
    [_teacherName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(teacherImg.mas_top);
        make.left.equalTo(teacherImg.mas_right).offset(6);
        make.height.equalTo(@(13));
    }];
    _teacherName.font =[UIFont systemFontOfSize:14];
    _teacherName.text = @"Jerry";
    _teacherName.textColor =[UIColor colorWithHex:0x9c5000];
    
    
    
//    UIImageView *placeImg =[[UIImageView alloc]init];
//    [backView addSubview:placeImg];
//    
//    _place =[[UILabel alloc]init];
//    [backView addSubview:_place];
//    
//    [placeImg mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(_courseName.mas_bottom).offset(11);
//        make.left.equalTo(_teacherName.mas_right).offset(13);
//        make.width.equalTo(@(13));
//        make.height.equalTo(@(13));
//    }];
//    placeImg.image =[UIImage imageNamed:@"cur_campus"];
//    
//    
//    [_place mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(placeImg.mas_top);
//        make.left.equalTo(placeImg.mas_right).offset(6);
//    }];
//    _place.numberOfLines = 0;
//    _place.textColor = [UIColor colorWithHex:0x9c5000];
//    _place.font =[UIFont systemFontOfSize:14];
//    _place.text = @"北京校区";
//    
//    UIImageView *placeDeImg =[[UIImageView alloc]init];
//    [backView addSubview:placeDeImg];
//    [placeDeImg mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(_courseName.mas_bottom).offset(11);
//        make.left.equalTo(_place.mas_right).offset(13);
//        make.width.equalTo(@(13));
//        make.height.equalTo(@(13));
//    }];
//    placeDeImg.image =[UIImage imageNamed:@"cur_campus"];
//
//    _placeDatial =[[UILabel alloc]init];
//    [backView addSubview:_placeDatial];
//    [_placeDatial mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(placeDeImg.mas_top);
//        make.left.equalTo(placeDeImg.mas_right).offset(6);
//    }];
//    _placeDatial.numberOfLines = 0;
//    _placeDatial.textColor = [UIColor colorWithHex:0x9c5000];
//    _placeDatial.font =[UIFont systemFontOfSize:14];
//    _placeDatial.text = @"海淀教室";
    
    return baseView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
